# Contributor: Michael Zuo <muh.muhten@gmail.com>
# Maintainer: Michael Zuo <muh.muhten@gmail.com>
pkgname=lua-fun
_rockname=fun
_pkgname=luafun
pkgver=0.1.3
pkgrel=10
pkgdesc="Functional programming library"
url="https://rtsisyk.github.io/luafun/"
arch="noarch"
license="MIT"
depends="lua"
checkdepends="luajit"
source="$pkgname-$pkgver.tar.gz::https://github.com/rtsisyk/$_pkgname/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

_luaversions="5.1 5.2 5.3 5.4"
for _v in $_luaversions; do
	checkdepends="$checkdepends lua$_v"
	provides="$provides lua$_v-${pkgname#lua-}=$pkgver-r$pkgrel"  # for backward compatibility
done

check() {
	local lver; for lver in $_luaversions jit; do
		msg "Testing on Lua $lver"
		lua$lver tests/runtest tests/*.lua
	done
}

package() {
	install -m 644 -D fun.lua "$pkgdir"/usr/share/lua/common/fun.lua

	echo 'rock_manifest = {}' > rock_manifest
	install -D -m 644 rock_manifest \
		"$pkgdir"/usr/lib/luarocks/rocks-common/$_rockname/$pkgver-1
}

sha512sums="1959c22453a6f431e4f4ee1ca1e6001c126f8857e00b128e5303049fd574150a68b71490503356f11fefcbd0ef7fbac7b0ae7c182a395ad0c92d2047dfac0662  lua-fun-0.1.3.tar.gz"
